$(function () {
    // 获取本地存储对象
    var localStorage = window.localStorage;
    var confirmMID = localStorage.getItem("key");
    console.log(confirmMID);
    $.post("http://localhost:8081/study/permission/findAllRole", {
        confirmMID: confirmMID
    }, function (data) {
        console.log(data)
        var arrays = data.data;
        var innerHtml = "";
        $.each(arrays, function (index, data) {
            innerHtml += "<tr><td>" + data.roleName + "</td><td>" + data.fatherLeaf + "</td><td>" + data.creator + "</td><td>" + data.createTime + "</td><td>" + data.remark + "</td><td><a class='btn btn-success' href='html/roleDetail.html?roleId=" + data.id + "'>详情</a><a class='btn btn-danger' onclick='deleteChoose(" + data.id + ");' href='javascript:void(0);'>删除</a></td>";
        });
        $("#tbodyContent").html(innerHtml);
    })
})

function deleteChoose(a) {
    var msg = "如果该角色有对应子级角色,也会一并删除,您确定要删除吗";
    if (
        confirm(msg) == true
    ) {
        $.post("permission/deleteRoleById", {
            roleId: a
        }, function (data) {
            if (data.success) {
                alert(data.message)
                window.location.href = "html/findAllRole.html"
            } else {
                alert(data.message)
            }
        })
    } else {
        return;
    }
}